const url = require("url");
let parseUrl = 'http://www.baidu.com/index.html?name=zhangsan&age=18'
let urlObj = url.parse(parseUrl);
console.log(urlObj);

/**
 * Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'www.baidu.com',
  port: null,
  hostname: 'www.baidu.com',
  hash: null,
  search: '?name=zhangsan&age=18',
  query: 'name=zhangsan&age=18',
  pathname: '/index.html',
  path: '/index.html?name=zhangsan&age=18',
  href: 'http://www.baidu.com/index.html?name=zhangsan&age=18'
}
 */
